$(document).ready(function(){
  $("#SearchSubmit").click(function(){
    var temp = 0;
    $.post("fifth_page.php",{
      sid:$("#sid").val(),
      cid:$("#cid").val(),
      cname:$("#cname").val(),
      classnum:$("#classnum").val()
    },function(data){
      // console.log(data)；
     var obj = eval("("+data+")");
     var total = 0;
     var totalpoint=0;
     $.each(obj,function(key,value){//计算平均分
      if(value.score<=0){
        value.score=0;//对于标记为-1的分进行筛查
        value.point=0;
      }

      total+=value.point*value.score;
      totalpoint+=value.point*1;
      });
     if(total==0||totalpoint==0)
      total=0;
    else
     total=total/totalpoint;
     document.getElementById("show_score").innerHTML=total;
    });
  });

});


$(document).ready(function(){
  $("#SearchSubmit").click(function(){
    $.post("fifth_page.php",{
      sid:$("#sid").val(),
      cid:$("#cid").val(),
      cname:$("#cname").val(),
      classnum:$("#classnum").val()
    },function(data){
      // console.log(data)；
     var obj = eval("("+data+")");
     $.each(obj,function(key,value){
        $("#table_score_info2").append("<tr>"+
      "<th>"+value.name+"</th>"+
      "<th>"+value.sid+"</th>"+
      "<th>"+value.cid+"</th>"+
      "<th>"+value.cname+"</th>"+
      "<th>"+value.point+"</th>"+
      "<th>"+value.score+"</th>"+
      "</tr>");
      });
    });

  });

});



var infoarr = Array();
$(document).ready(function(){
  $("#SearchSubmit").click(function(){
    $.post("chartinfo.php",{
      sid:$("#sid").val(),
      cid:$("#cid").val(),
      cname:$("#cname").val(),
      classnum:$("#classnum").val()
    },function(data){
      // console.log(data);
     $("#echarts").empty();//清空饼状图缓存
     var obj = eval("("+data+")");
     $.each(obj,function(key,value){
      console.log(value)
      $("#echarts").empty();//清空饼状图缓存
      infoarr.push({value:value.total, name:value.name});
    });
     
     //建立图标
      var myChart = echarts.init(document.getElementById('echarts'));

var option = {
    tooltip: {
        trigger: 'item',
        formatter: "{a} <br/>{b}: {c} ({d}%)"
    },
    legend: {
        orient: 'vertical',
        x: 'left',
        //（不及格，60－69，70－79，80－89，90－99，满分）
        // data:['不及格','60－69','70－79','80－89','90－99','满分']
    },
    series: [
        {
            name:'人数',
            type:'pie',
            radius: ['50%', '70%'],
            avoidLabelOverlap: false,
            label: {
                normal: {
                    show: false,
                    position: 'center'
                },
                emphasis: {
                    show: true,
                    textStyle: {
                        fontSize: '30',
                        fontWeight: 'bold'
                    }
                }
            },
            labelLine: {
                normal: {
                    show: false
                }
            },
            data:infoarr
            // [
            //     {value:335, name:'不及格'},
            //     {value:310, name:'60－69'},
            //     {value:234, name:'70－79'},
            //     {value:135, name:'80－89'},
            //     {value:1548, name:'90－99'},
            //     {value:1548, name:'满分'}
            // ]
        }
    ]
};
        myChart.setOption(option);
//// 基于准备好的dom，初始化echarts实例
    });

  });

});

//环形图



